package com.bbva.kyfb.kyfbjpatlsb.dominiotlsb;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbfrf.
 */
@Entity
@Table(name = "TTLSBFRF",schema = "TLSB")
@Configurable
@RooJavaBean
@RooToString
@RooEntity(identifierType = TtlsbfrfPK.class, versionField = "",  persistenceUnit="persistenceUnitTLSB", table = "TTLSBFRF", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLSB")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbfrf {

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");                
        sb.append("CodNumaleat: ").append(getCodNumaleat()).append(", ");
        sb.append("Id: ").append(getId()).append(", ");
        sb.append("XsnFirmado: ").append(getXsnFirmado()).append(", ");
        return sb.toString();
    }

	/** The entity manager. */
	@PersistenceContext(unitName="persistenceUnitTLSB")
    transient EntityManager entityManager;

	/** The id. */
	@EmbeddedId
    private TtlsbfrfPK id;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public TtlsbfrfPK getId() {
        return this.id;
    }

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(TtlsbfrfPK id) {
        this.id = id;
    }

	/**
	 * Persist.
	 */
	@Transactional(value="tlsb")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	/**
	 * Removes the.
	 */
	@Transactional(value="tlsb")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbfrf attached = Ttlsbfrf.findTtlsbfrf(this.id);
            this.entityManager.remove(attached);
        }
    }

	/**
	 * Flush.
	 */
	@Transactional(value="tlsb")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	/**
	 * Clear.
	 */
	@Transactional(value="tlsb")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	/**
	 * Merge.
	 *
	 * @return the ttlsbfrf
	 */
	@Transactional(value="tlsb")
    public Ttlsbfrf merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbfrf merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	/**
	 * Entity manager.
	 *
	 * @return the entity manager
	 */
	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbfrf().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	
	/**
	 * Count ttlsbfrfes.
	 *
	 * @return the long
	 */
	@Transactional(value="tlsb")
	public static long countTtlsbfrfes() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbfrf o", Long.class).getSingleResult();
    }

	
	/**
	 * Find all ttlsbfrfes.
	 *
	 * @return the list
	 */
	@Transactional(value="tlsb")
	public static List<Ttlsbfrf> findAllTtlsbfrfes() {
        return entityManager().createQuery("SELECT o FROM Ttlsbfrf o", Ttlsbfrf.class).getResultList();
    }

	
	/**
	 * Find ttlsbfrf.
	 *
	 * @param id the id
	 * @return the ttlsbfrf
	 */
	@Transactional(value="tlsb")
	public static Ttlsbfrf findTtlsbfrf(TtlsbfrfPK id) {
        if (id == null) return null;
        return entityManager().find(Ttlsbfrf.class, id);
    }

	
	/**
	 * Find ttlsbfrf entries.
	 *
	 * @param firstResult the first result
	 * @param maxResults the max results
	 * @return the list
	 */
	@Transactional(value="tlsb")
	public static List<Ttlsbfrf> findTtlsbfrfEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbfrf o", Ttlsbfrf.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }

	/** The cod numaleat. */
	@Column(name = "COD_NUMALEAT",columnDefinition = "CHAR", length = 9)
    @NotNull
    private String codNumaleat;

	/** The xsn firmado. */
	@Column(name = "XSN_FIRMADO",columnDefinition = "CHAR")
    @NotNull
    private Character xsnFirmado;

	/** The aud usuario. */
	@Column(name = "AUD_USUARIO",columnDefinition = "CHAR", length = 8)
    @NotNull
    private String audUsuario;

	/** The aud fmodific. */
	@Column(name = "AUD_FMODIFIC",columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	
	/**
	 * Gets the cod numaleat.
	 *
	 * @return the cod numaleat
	 */
	public String getCodNumaleat() {
        return this.codNumaleat;
    }

	/**
	 * Sets the cod numaleat.
	 *
	 * @param codNumaleat the new cod numaleat
	 */
	public void setCodNumaleat(String codNumaleat) {
        this.codNumaleat = codNumaleat;
    }

	/**
	 * Gets the xsn firmado.
	 *
	 * @return the xsn firmado
	 */
	public Character getXsnFirmado() {
        return this.xsnFirmado;
    }

	/**
	 * Sets the xsn firmado.
	 *
	 * @param xsnFirmado the new xsn firmado
	 */
	public void setXsnFirmado(Character xsnFirmado) {
        this.xsnFirmado = xsnFirmado;
    }

	/**
	 * Gets the aud usuario.
	 *
	 * @return the aud usuario
	 */
	public String getAudUsuario() {
        return this.audUsuario;
    }

	/**
	 * Sets the aud usuario.
	 *
	 * @param audUsuario the new aud usuario
	 */
	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	/**
	 * Gets the aud fmodific.
	 *
	 * @return the aud fmodific
	 */
	public Date getAudFmodific() {
        return this.audFmodific;
    }

	/**
	 * Sets the aud fmodific.
	 *
	 * @param audFmodific the new aud fmodific
	 */
	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }
}
